package com.zj.HJ;

import java.util.Scanner;

public class HJ55 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        System.out.println(getRes(num));
    }

    public static int getRes(int num) {
        int count = 0;
        for (int i = 1; i < num; i++) {
            if (i % 7 == 0) {
                count++;
            } else if (String.valueOf(i).indexOf("7") > -1) {
                count++;
            }
        }
        return count;
    }


}
